#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5, SZ = 1e6 + 5;
int T, n, m, L, V, cnt = 0;
int d[N], v[N], a[N], p[N], s[SZ];
pair<int, int> b[N];

inline int sum(int l, int r) {
	return l ? s[r] - s[l - 1] : s[r];
}

int main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> T;
	while (T--) {
		cin >> n >> m >> L >> V;
		for (int i = 1; i <= n; ++i) cin >> d[i] >> v[i] >> a[i];
		for (int i = 1; i <= m; ++i) cin >> p[i], ++s[p[i]];
		for (int i = 1; i <= L; ++i) s[i] += s[i - 1];
		cnt = 0;
		for (int i = 1; i <= n; ++i) {
			if (v[i] <= V) {
				if (a[i] > 0) {
					int q = d[i] + (V * V - v[i] * v[i]) / (2 * a[i]) + 1;
					if (q <= L && sum(q, L)) b[++cnt] = pair<int, int>(q, L);
				}
			} else {
				if (a[i] >= 0) {
					if (sum(d[i], L)) b[++cnt] = pair<int, int>(d[i], L);
				} else {
					int q = min(L, d[i] + (v[i] * v[i] - V * V - 1) / (-2 * a[i]));
					if (d[i] <= q && sum(d[i], q)) b[++cnt] = pair<int, int>(d[i], q);
				}
			}
		}
		cout << cnt << ' ';
		if (cnt) {
			for (int i = 1; i <= cnt; ++i) {
				b[i].first = lower_bound(p + 1, p + m + 1, b[i].first) - p;
				b[i].second = upper_bound(p + 1, p + m + 1, b[i].second) - p - 1;
			}
			sort(b + 1, b + cnt + 1);
			int r = b[1].second, ans = 1;
			for (int i = 2; i <= cnt; ++i) {
				if (b[i].first > r) {
					++ans;
					r = b[i].second;
				} else {
					r = min(r, b[i].second);
				}
			}
			cout << m - ans << '\n';
		} else {
			cout << m << '\n';
		}
		for (int i = 0; i <= L; ++i) s[i] = 0;
	}
	return 0;
}
